#include <zmq.hpp>
#include <string>
#include <iostream>

int main() {
    zmq::context_t context(1);
    zmq::socket_t subscriber(context, ZMQ_SUB);
    subscriber.connect("tcp://localhost:5556");  			// 连接到发布者
    subscriber.set(zmq::sockopt::subscribe, "");  			// 订阅所有消息

    while (true) {
        zmq::message_t update;
        subscriber.recv(update, zmq::recv_flags::none);
        std::string data(static_cast<char*>(update.data()), update.size());
        std::cout << "Received update: " << data << std::endl;
    }
    return 0;
}